 //购物车搜索信息框
 const search = document.querySelector(".search");
 const showlist = document.querySelector(".showSearch ul");
 const parentshowlist = document.querySelector(".showSearch");
 const getData = function(data) {
     // console.log(data);
     let str = "";
     for (let val in data) {
         str += `
             <li>
                 <span class="prespan">${val}</span>
                 <span>约${data[val]}个结果</span>
             </li>
             `;
     }
     showlist.innerHTML = str;
 }

 let timer = null;
 search.oninput = function() {
     if (search.value) {
         showlist.style.display = "block";
         parentshowlist.style.display = "block";
     } else {
         showlist.style.display = "none";
         parentshowlist.style.display = "none";
     }
     const preScript = document.querySelector("#onlyone");
     if (preScript) {
         preScript.remove();
     }
     let currentScript = document.createElement("script");
     let currentSrc = "https://search.ule.com/api/suggest.action?callback=getData&query=" + search.value + "&_=1618898709613";
     currentScript.id = "onlyone";
     currentScript.src = currentSrc;
     document.body.appendChild(currentScript);

 }
 search.onblur = function() {
     showlist.style.display = "none";
     parentshowlist.style.display = "none";
 }